<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索</title>
    <link rel="icon" href="/mi/imgs/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="/mi/css/common/header.css">
    <link rel="stylesheet" href="/mi/css/product/search.css">
    <link rel="stylesheet" href="/mi/css/iconfont/iconfont.css">
    <link rel="stylesheet" href="/mi/css/iconfont/iconfont.css">
    <link rel="stylesheet" href="/mi/css/common/page_bottom.css">
    <style>

        .mi-pagenav {
            height: 30px;
            padding: 15px 0;
            text-align: center;
        }

        .numbers {
            display: inline-block;
            width: 48px;
            height: 24px;
            padding: 3px 0;
            margin: 0 5px;
            font-size: 18px;
            font-weight: 200;
            line-height: 24px;
            color: #b0b0b0;
        }

        .ico {
            font-size: 24px;
            vertical-align: bottom;
        }

        .current1 {
            background-color: #757575;
            color: #fff;
        }
    </style>
</head>

<body style="margin: 0px;">
<div class="app">
    <%@include file="../common/header.jsp" %>
    <div class="mi-search">
        <div class="container">
            <div class="search-container">
                <div class="container-main">
                    <div class="breadcrumbs">
                        <div class="container">
                            <a href="#">首页</a>
                            <span class="sep">></span>
                            <a href="#">搜索</a>

                        </div>

                    </div>
                    <div id="search_outer">

                    </div>

                    <c:if test="${user!=null && productlist!='nulls'}">
                        <div class="search-favourite">
                            <div class="mi-recommend cart-recommend">
                                <h2 class="recommend-title">
                                    <span>猜你喜欢</span>
                                </h2>

                                <div class="recommend-bd">

                                    <ul class="recommend-list swiper-wrapper">
                                        <input type="hidden" id="likesize" value="${productlistsize}">
                                        <c:forEach items="${productlist}" var="i" varStatus="count">
                                            <c:if test="${count.count<=8}">
                                            <li class="recommend-item swiper-container">
                                                <a>
                                                    <div class="fastRImg">
                                                        <img src="${i.picImg}" width="140px">
                                                    </div>
                                                    <div class="recommend-name">${i.productName}</div>
                                                    <div class="recommend-price">${i.price}</div>
                                                    <div class="recommend-tips">66.5万人好评</div>
                                                    <a class="add_gobuy" href="/mi/cart/add_cart?productId=${i.productId}">立即购买</a>
                                                </a>
                                            </li>
                                            </c:if>
                                        </c:forEach>

                                    </ul>

                                    <div class="swiper-controls">
                                        <span class="control-btn control-left "><i class="iconfont icon-youjiantou"></i></span>
                                        <span class="control-btn control-right"><i
                                                class="iconfont icon-icon"></i></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </c:if>
                </div>
            </div>
        </div>
    </div>

    <!-- 底部公共部分 -->
    <%@include file="../common/page-bottom.jsp" %>
</div>
<input type="hidden" value="${productName}" id="productName">

<script type="text/javascript" src="/mi/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/mi/js/product/search.js"></script>
<script>
    $(function () {
        let pname = $("#pname").val();
        if (pname==0&&document.getElementById("productName").value==0){
            $("#search_outer").load("/mi/product/search", {
                pageNum: 1,
                categoryId: -1,
                // productName: document.getElementById("productName").value,
                orderNumber: null
            });
        }else{
            $("#search_outer").load("/mi/product/search/query02?text="+document.getElementById("productName").value);
        }

        // $("#search_outer").load("/mi/product/search", {
        //     // pageNum: 1,
        //     // categoryId: -1,
        //     text: document.getElementById("productName").value,
        //     // orderNumber: null
        // })
    })

    function choice(object) {
        $("#search_outer").load("/mi/product/search", {categoryId: object.value});

    }


    function search_go() {
        let pname = $("#pname").val();
        let ptype = $("#ptype").val();
        if (pname==0){
            $("#search_outer").load("/mi/product/search", {
                pageNum: 1,
                categoryId: -1,
                // productName: document.getElementById("productName").value,
                orderNumber: null
            });
        }else {
            $("#search_outer").load("/mi/product/search/query02?text="+pname.trim());
        }
        // if (pname.trim()) {
        //     // $.get('/mi/search/so?text=' + pname.trim(), {}, function (_data) {
        //     //     console.log(_data);
        //     // },"json");
        //     // $("#search_outer").load("/mi/product/search", {productName: pname, categoryId: ptype});
        //
        // }


    }

    function next_page(num) {
        let pname = $("#pname").val();
        let ptype = $("#ptype").val();
        $("#search_outer").load("/mi/product/search", {pageNum: num, productName: pname, categoryId: ptype});
    }

    function showresultstaging() {
        var productStage = document.getElementById("show-staging");
        var all = document.getElementById("search-all");
        if (productStage.display = "none") {
            all.style.display = "none";
            productStage.style.display = "block";
        }
    }

</script>

</body>

</html>